package com.flannery.demotest.keyboard;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Toast;

import com.flannery.demotest.R;
import com.flannery.keyboradlibrary.Keyboard;

public class KeyboardDemoActivity extends AppCompatActivity {

    public static void startKeyboardDemoActivity(Activity act) {
        act.startActivity(new Intent(act, KeyboardDemoActivity.class));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_keyboard_demo);

        initView();
/*        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });*/
    }

    private void showToast(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    private void initView() {
        ((Keyboard) findViewById(R.id.keyboard_test)).setOnKeyboardListener(new Keyboard.onKeyboardListener() {
            @Override
            public void onZeroPressed() {
                showToast("0");
            }

            @Override
            public void onOnePressed() {
                showToast("1");
            }

            @Override
            public void onTwoPressed() {
                showToast("2");
            }

            @Override
            public void onThreePressed() {
                showToast("3");
            }

            @Override
            public void onFourPressed() {
                showToast("4");
            }

            @Override
            public void onFivePressed() {
                showToast("5");
            }

            @Override
            public void onSixPressed() {
                showToast("6");
            }

            @Override
            public void onSevenPressed() {
                showToast("7");
            }

            @Override
            public void onEightPressed() {
                showToast("8");
            }

            @Override
            public void onNinePressed() {
                showToast("9");
            }

            @Override
            public void onAddPressed() {
                showToast("+");
            }

            @Override
            public void onSubPressed() {
                showToast("-");
            }

            @Override
            public void onMultiPressed() {
                showToast("x");
            }

            @Override
            public void onDiviPressed() {
                showToast("÷");
            }

            @Override
            public void onClearPressed() {
                showToast("c");
            }

            @Override
            public void onOkPressed() {
                showToast("OK");
            }
        });
    }

}
